package com.tanhua.model.vo;

import com.tanhua.model.db.UserInfo;
import com.tanhua.model.mongo.Video;
import com.tanhua.model.mongo.VideoComment;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class VideoCommentVo {

    //用户信息
    private Long userId;
    private String avatar; //头像
    private String nickname; //昵称

    //详情
    private String content; //评论内容
    private String createDate; //评论时间（1是，0否）
    private Integer likeCount = 0; //点赞数
    private Integer hasLiked; //是否点赞（1是，0否）

    public static VideoCommentVo init(UserInfo userInfo, VideoComment item) {
        VideoCommentVo vo = new VideoCommentVo();
        //copy用户属性
        BeanUtils.copyProperties(userInfo,vo);  //source,target
        //copy视频详情
        BeanUtils.copyProperties(item,vo);
        vo.setContent(item.getContent());
        long timeMillis = System.currentTimeMillis();
        String createDate = String.valueOf(timeMillis);
        vo.setCreateDate(createDate);
        vo.setHasLiked(0);

        return vo;
    }

}
